// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import ComponentBase from "../../../../general/Script/component/ComponentBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Comb extends ComponentBase {

    @property([cc.SpriteFrame])
    numberSp:cc.SpriteFrame[] = [];
    
    count:cc.Node = null;


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    
    setNumber(num:number){
        const string = num-1>0?(num-1).toString():'';
        this.count.getComponent(cc.Label).string = string;
        

    }

    runCombAction(cb){
        const scale = this.node.scale;
        this.node.scale = scale*0.01;
        this.node.runAction(cc.sequence(cc.scaleTo(0.3,scale).easing(cc.easeBackInOut()),cc.delayTime(0.5),cc.fadeOut(0.3),cc.callFunc(()=>{
            this.node.removeFromParent();
            this.node.destroy();
            cb();
        })));

        this.count.runAction(cc.sequence(cc.delayTime(0.2),cc.scaleTo(0.1,1.5).easing(cc.easeIn(2)),cc.scaleTo(0.2,1).easing(cc.easeOut(2))));
    }

    // update (dt) {}
}
